home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-10-20 | 2.3 KB | 92 lines | [TEXT/GEOL] |
- Item 0778683 19-Oct-89 08:48
-
- From: MADA.EUROPE MacApp Dev Assoc Europe, E Carrasco
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: RE-Window Menu recipe
-
- From: Father Vincent
-
- To: MacApp.Tech$
-
- Sub: An improvement to the WindowMenu recipe
- (written on a French BBS, Father Vincent isn't yet on AppleLink, Eric)
-
-
- Hi all,
-
- I have implemented the same function in an application with a very
- similar method. I have also added a functionnality to change the menu item
- when the document title changes. Here is my method.
-
- {$S ANonRes}
- procedure TMyApplication.ChangeMenuWindowName(var aNewTitle, aOldTitle:
- Str255);
- var wMenuHdl: MenuHandle;
- aName: Str255;
- item: integer;
- itemCount: integer;
- done: Boolean;
- begin
- wMenuHdl := GetMHandle(mWindowMenu);
- if wMenuHdl <> NIL then
- begin
- itemCount := CountMItems(wMenuHdl);
- item := cRegularWMItems;
- done := false;
-
- repeat
- item := item + 1;
- GetItem(wMenuHdl, item, aName);
- if aName = aOldTitle then
- begin
- aName := aNewTitle;
- SetItem(wMenuHdl, item, aName);
- done := true;
- end;
- until done or (item >= itemCount);
- end;
- end;
-
-
- {$S ANonRes}
- PROCEDURE TMyDocument.SetTitle(aTitle: Str255); override;
- { To record the old name of the document when the title changes during a
- "save as" command }
- begin
- if fOldTitle = NIL then { Only for the initialisation time }
- fOldTitle := NewString(aTitle);
- end;
-
-
- {$S AWriteFile}
- PROCEDURE TMyDocument.SavedOn(VAR fileName: Str255; volRefNum: INTEGER);
- OVERRIDE;
-
- VAR oldTitle: Str255;
-
- BEGIN
- INHERITED SavedOn(fileName, volRefNum);
-
- { Own stuff }
-
- { Changes the text of the menu item when the name of the document
- changes }
-
- { Note fOldTitle is a field of TMyDocument }
-
- if (fOldTitle <> NIL) ë (fileName <> fOldTitleîî) then
- begin
- oldTitle := fOldTitleîî; { To prevent Heap moving }
- TMyApplication(gApplication).ChangeMenuWindowName(fileName,
- oldTitle);
-
- DisposIfHandle(fOldTitle);
- fOldTitle := NewString(fileName);
- end;
- END;
-
- Father Vincent
-
-